<template>
	<view class="content">
		<view class="top">
			<h3>时尚简约商城</h3>
		</view>\
		<view class="main">
			<view class="scr" @click="enter">搜索<image class="imagesrc" src="../../static/scrlogo.png" mode=""></image>
			</view>
		</view>

		<view class="color">
			<view class="color-1" v-for="(item,index) in nav" @click="tableto(item)" :key="index">
				<image src="@/static/tablelogo2.png" mode=""></image>
				<text>{{item.title}}</text>
			</view>
		</view>
		<view class="images">
			<view class="imagesmax" v-for="item,i in RubikCube">
				<!-- <image src="../../static/tablelogo6.png" mode=""></image> -->
			</view>
		</view>
		<view class="texttop">
			<text>优惠专区</text>
		</view>
		<!-- 轮播图 商品图片 -->
		<view class="swiper">
			<!-- <image :src="ImageAds[0].imageUrl" mode=""></image> -->
		</view>
		<!-- 商品渲染列表 -->
		<view class="bottom">
			<view v-for="item,i in goodlist" class="botto-min">
				<image src="../../static/tablelogo2.png" mode=""></image>
				<text>{{item.cost_price}}</text>
				<text>已售{{item.goods_number}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {list} from "uview-ui/libs/config/props/list";
	import {
		indexinit,goodsindex
	} from "../../utils/ajax.js"
	export default {
		data() {
			return {
				list: [],
				nav: [], //跳转导航
				RubikCube: [], //商品图
				ImageAds: [], //商品轮播
				Goodsid:"" ,//商品列表
				goodlist:[] //商品渲染
			}
		},
		onLoad() {
			indexinit({
				shop_id: 1
			}).then(res => {
				// 总数据
				this.list = res.data.data.value
				// 图文导航数据
				for (let i = 0; i < this.list.length; i++) {
					if (this.list[i].componentName == "GraphicNav") {
						this.nav = this.list[i].list
					}
					if (this.list[i].componentName == "RubikCube") {
						this.RubikCube = this.list[i].list
					}
					if (this.list[i].componentName == "ImageAds") {
						this.ImageAds = this.list[i].list
					}
					if(this.list[i].componentName == "GoodsList"){
						this.Goodsid=this.list[i].goodsId.join(",")						
					}
				}
				goodsindex({
					shop_id: 1,
					goods_id:this.Goodsid
				}).then(res=>{
					// console.log(res.data.data.data);
					this.goodlist=res.data.data.data
					console.log(this.goodlist);
				})

			})
		
			
		},
		
		beforeMount() {
			
		},
		methods: {
			// 搜索跳转
			enter() {
				uni.navigateTo({
					url: "/pages/search/search"
				});
			},
			// 跳转页面
			tableto(item) {
				uni.navigateTo({
					url: `/pages/particular/particular?id=${item.id}`
				});
			}

		}
	}
</script>

<style lang="scss">
	* {
		margin: 0;
		padding: 0;

	}

	.top {
		width: 100%;
		height: 100rpx;
		position: fixed;
		text-align: center;
		background-color: white;
		z-index: 555;
	}

	.top h3 {
		margin-top: 25rpx;
	}

	.main {
		width: 100%;
		background-color: #f5f5f5;
		margin-top: 50rpx;
		padding: 30rpx 10rpx;
		box-sizing: border-box;
	}

	.scr {
		width: 700rpx;
		height: 90rpx;
		background-color: white;
		margin: 0 auto;
		border-radius: 50rpx;
		box-sizing: border-box;
		padding: 25rpx;
		color: #8a8a8a;
		font-size: 30rpx
	}

	.imagesrc {
		width: 40rpx;
		height: 40rpx;
		position: absolute;
		right: 50rpx;
	}

	.color {
		background-color: #f5f5f5;
		height: 380rpx;
		display: flex;
		justify-content: space-around;
		flex-wrap: wrap;
		font-size: 20rpx;
		text-align: center;

	}

	.color-1 image {
		width: 100rpx;
		height: 100rpx;
		display: flex;
		margin-left: 50rpx;
		position: relative;
		left: -25rpx;
	}

	.images {
		width: 700rpx;
		height: 500rpx;
		margin: 0 auto;
		display: flex;
		flex-direction: column;
		flex-wrap: wrap;
		// float: left;
	}

	.imagesmax {
		width: 100rpx;
		height: 100rpx;
		background-color: pink;
	}

	.images .imagesmax:nth-child(1) {
		width: 300rpx;
		height: 500rpx;
		background-color: pink;
		background-color: black;
		border-top-left-radius: 30rpx;
		border-bottom-left-radius: 30rpx;
		overflow: hidden;
	}

	.images .imagesmax:nth-child(2) {
		width: 368rpx;
		height: 236rpx;
		background-color: pink;
		margin-left: 10rpx;
		border-top-right-radius: 30rpx;
	}

	.images .imagesmax:nth-child(3) {
		width: 368rpx;
		height: 236rpx;
		background-color: pink;
		background-color: #8a8a8a;
		margin-top: 25rpx;
		margin-left: 10rpx;
		border-bottom-right-radius: 30rpx;
	}

	.images image {
		width: 100%;
		height: 100%;
	}

	.texttop {
		width: 700rpx;
		height: 100rpx;
		background-color: pink;
		margin: 20rpx auto;
		border-top-left-radius: 30rpx;
		border-top-right-radius: 30rpx;
		padding-left: 20rpx;
		box-sizing: border-box;
	}

	.texttop text {
		line-height: 100rpx;
		font-size: 30rpx;
		font-weight: 900
	}

	.swiper {
		width: 700rpx;
		height: 300rpx;
		margin: 20rpx auto;
		background-color: pink;
		border-radius: 30rpx;
		overflow: hidden;
	}
	.bottom{
		width: 700rpx;
		background-color: white;
		margin: 0 auto;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		text-align: center;
	}
	.bottom .botto-min{
		width: 340rpx;
		height: 300rpx;
		background-color: pink;
	}
	.bottom  image{
		width: 300rpx;
		height: 200rpx;
		margin-left: 20rpx;
	}
</style>
